﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
public partial class Admin_Chitietlienhe : System.Web.UI.Page
{
    BUS_Contact BUSC = new BUS_Contact();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["lh"] != null && Request.QueryString["id"] != null && Request.QueryString["lh"] != "" && Request.QueryString["id"] != "")
            {
                int lh = int.Parse(Request.QueryString["lh"].ToString());
                int id = int.Parse(Request.QueryString["id"].ToString());
                LoadData(lh, id);
            }
            else
            {
            }
        }
    }
    protected void LoadData(int lh, int id)
    {
        DataTable dt = new DataTable();

        switch (lh)
        {
            case 1:
                lblActive_breadcrumb.Text = "Chưa xử lý";
                lTitle.Text = "Chưa xử lý";
                dt = BUSC.Contact_getById(1, lh, id);
                pnButton.Visible = true;
                break;
            case 2:
                lblActive_breadcrumb.Text = "Đã Duyệt";
                lTitle.Text = "Đã duyệt";
                dt = BUSC.Contact_getById(0, lh, id);
                pnButton.Visible = false;
                break;
            default:
                lblActive_breadcrumb.Text = "Chưa xử lý";
                lTitle.Text = "Chưa xử lý";
                dt = BUSC.Contact_getById(1, lh, id);
                pnButton.Visible = true;
                break;
        }
        rptChitietLH.DataSource = dt;
        rptChitietLH.DataBind();
    }
    protected void btnDuyetLH_Click(object sender, EventArgs e)
    {
        TextBox txtid = (TextBox)rptChitietLH.Items[0].FindControl("txtid");
        DTO_Contact dtoC = new DTO_Contact();
        int id = int.Parse(txtid.Text.ToString());
        dtoC.ID = id;
        dtoC.Status = 0;
        if (BUSC.Contact_Update(dtoC))
        {
            Response.Redirect("~/admin/lienhe.aspx");
        }
    }
}